﻿/*-------------------------------------------------------------------------
* 命名空间: WaferSelectV3.Services/DialogProvider
* 类       名: DialogProvider
* 功      能:  TD
* 时      间:  2024-04-25 11:28:25
* 版      本:  V1.0
* 作      者:  Fioman
* 格      言:  Talk is cheap,show me the code ^_^
*-------------------------------------------------------------------------*/
using Prism.Ioc;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using WaferSelectV3.Dialogs;

namespace WaferSelectV3.Services
{
    public class DialogProvider
    {
        private static IDialogService? _dialogService;

        public static void SetDialogService(IDialogService dialogService)
        {
            _dialogService = dialogService;
        }

        // 并且不需要返回值,如果是非模态内部就使用_dialogService.Show(),如果是模态内部就使用_dialogService.ShowDialog()
        public static void Show(string dialogName, IDialogParameters parameters)
        {
            IDialogResult dialogResult = new DialogResult();
            // 弹设置页面窗口,这里不需要返回值,所以用Show
            if (dialogName == nameof(SetParametersDialog))
            {
                // 非模态弹窗
                _dialogService!.Show(dialogName, parameters, result => { });
            }
            else if (dialogName == nameof(DataInitProcessBar))
            {
                _dialogService!.Show(dialogName, parameters, result => { });
            }
            else if (dialogName == nameof(AddUserDialog))
            {
                _dialogService!.ShowDialog(dialogName, parameters, result => { });
            }
            else if (dialogName == nameof(EditeUserDialog))
            {
                _dialogService!.ShowDialog(dialogName, parameters, result => { });
            }
        }

        public static IDialogResult ShowDialog(string dialogName, IDialogParameters parameters)
        {
            IDialogResult dialogRes = new DialogResult();
            // 异常弹窗
            if (dialogName == nameof(ExceptionDialog))
            {
                _dialogService!.ShowDialog(dialogName, parameters, result =>
                {
                    dialogRes = result;
                });
            }
            else if (dialogName == nameof(ExceptionDetailDialog))
            {
                // 异常详情页弹窗
                _dialogService!.ShowDialog(dialogName, parameters, result =>
                {
                    dialogRes = result;
                });
            }
            else if (dialogName == nameof(InputNextCrystalDialog))
            {
                // 输入下一页弹窗
                _dialogService!.ShowDialog(dialogName, parameters, result =>
                {
                    dialogRes = result;
                });
            }
            return dialogRes;
        }
    }
}


